import React, { Component } from "react";
import { withRouter } from "react-router-dom";
import { Button } from "antd";
import 'antd/dist/reset.css';

class Header extends Component {
  back = () => {
    this.props.history.goBack();
  };

  render() {
    return (
      <div className="page-header">
        <h2>React Router Demo</h2>
        <button onClick={this.back}>后退</button>
        <Button type="primary">Click</Button>
      </div>
    );
  }
}
// withRouter能够将一般组件加工，让一般组件具备路由组件所特有的API
// withRouter的返回值是一个新组件
export default withRouter(Header);
